package everything.search;

public class ASearchNode implements Comparable<ASearchNode> {
	private SearchAgentState _state;
	private ASearchNode _parent;
	private int _value;
	private String _moveToMake;
	private int _depth;

	public ASearchNode(SearchAgentState state, ASearchNode parent, String moveToMake) {
		_state = state;
		_parent = parent;
		_moveToMake = moveToMake;
		if (_parent == null){
			_depth = 0;
		} else {
			_depth = _parent.getDepth() + 1;
		}
		_value = 0;
	}

	public void setValue(SearchAgent agent){
		_value = agent.f(this);
	}

	public ASearchNode getParent() {
		return _parent;
	}

	public SearchAgentState getState() {
		return _state;
	}

	public int getValue() {
		return _value;
	}

	public String getMove(){
		return _moveToMake;
	}

	public int getDepth(){
		return _depth;
	}

	//@Override
	public int compareTo(ASearchNode o) {
		// return -1 if this.value is smaller
		if (o._value > _value) return -1;
		else if (o._value < _value) return 1;
		return 0;
	}
}
